<template>
  <div>
    <el-collapse-transition>
      <div
        id="FlowEditor-BottomPanel"
        :class="{
          'FlowEditor-BottomPanel--heightSelections': bottomPanelBool,
        }"
      >
        <div class="editor-bottom-panel">
          <button
            class="bottom-panel-arrow"
            @click="switchPanel"
            :disabled="tabPosition != 'canvas'"
          >
            <!-- <i class="el-icon-caret-bottom"></i> -->
            <!-- <i
              :class="[
                bottomPanelBool ? 'el-icon-caret-bottom' : 'el-icon-caret-top',
              ]"
            ></i> -->
            <i
              :class="[
                bottomPanelBool && tabPosition == 'canvas'
                  ? 'el-icon-caret-bottom'
                  : 'el-icon-caret-top',
              ]"
            ></i>
          </button>
        </div>
        <div class="panel" v-show="bottomPanelBool">
          <AmisRender
            v-show="tabName == 'AmisRender'"
            :schema="schema"
            :data="data"
          ></AmisRender>
          <Debugging
            :onRegisterStartS="onRegisterStartS"
            :clearData="clearData"
            v-show="tabName == 'Debugging'"
            :tabName="tabName"
            :bottomPanelBool="bottomPanelBool"
          ></Debugging>
        </div>
      </div>
    </el-collapse-transition>
  </div>
</template>
<script>
import { mapMutations } from "vuex";
import AmisRender from "@/components/Amis/AmisRender.vue";
import Debugging from "./Debugging";
export default {
  name: "BottomPanel",
  components: { AmisRender, Debugging },
  props: {
    tabName: {
      type: String,
      default: null,
    },
    onRegisterStartS: Function,
    clearData: Function,
    schema: {
      type: Object,
      default: () => {},
    },
    data: {
      type: Object,
      default: () => {},
    },
    tabPosition: {
      type: String,
      default: null,
    },
  },
  data() {
    return {
      // bottomPanelBool: this.tabPosition == "compile" ? false : false,
      bottomPanelBool: false,
    };
  },
  watch: {
    tabPosition: {
      handler(newV) {
        if (newV == "compile") {
          this.bottomPanelBool = false;
        }
      },
      deep: true,
      immediate: true,
    },
  },
  methods: {
    ...mapMutations(["setBottomPanelBool"]),
    switchPanel() {
      // this.setBottomPanelBool(!this.bottomPanelBool);
      this.bottomPanelBool = !this.bottomPanelBool;
      this.$emit("switchPanel", this.bottomPanelBool);
    },
  },
  computed: {
    // bottomPanelBool() {
    //   return this.$store.state.panel.bottomPanelBool;
    // },
  },

  mounted() {},
};
</script>
<style lang="less" scoped>
.editor-bottom-panel {
  position: relative;
}

.FlowEditor-BottomPanel--heightSelections {
  /* height: 400px; */
  height: 100%;
}

.editor-bottom-panel .bottom-panel-arrow {
  position: absolute;
  width: 50px;
  height: 16px;
  top: -6px;
  left: 50%;
  transform: translateY(-50%);
  background-color: transparent;
  box-sizing: border-box;
  z-index: 10;
  cursor: pointer;
  display: flex;
  /* flex-direction: column; */
  /* align-items: center; */
  justify-content: center;
}
button {
  border: none;
  outline: none;
  background: none;
}

.editor-bottom-panel .bottom-panel-arrow::before {
  content: "";
  position: absolute;
  border-radius: 10px 10px 0 0;
  box-sizing: border-box;
  border-right: 0;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background: #ddd;
  z-index: -1;
  /* transform: perspective(50px) rotateY(-30deg); */
  transition: all 0.15s;
}
</style>